package com.visiontech.volunteer_center;

import com.visiontech.volunteer_center.interceptor.AdministratorInterceptor;
import com.visiontech.volunteer_center.interceptor.UserInterceptor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@SpringBootApplication
public class VolunteerCenterApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(VolunteerCenterApplication.class, args);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration ir = registry.addInterceptor(new UserInterceptor());
        ir.addPathPatterns("/content/index_user");
        ir.addPathPatterns("/content/LFRX_user");
        ir.addPathPatterns("/content/select_user");
        ir.addPathPatterns("/content/insert_lfrx");

        InterceptorRegistration ir2 = registry.addInterceptor(new AdministratorInterceptor());
        ir2.addPathPatterns("/content/index_add");
        ir2.addPathPatterns("/content/index_administrator");
        ir2.addPathPatterns("/content/LFRX_administrator");
        ir2.addPathPatterns("/content/select_administrator");
        ir2.addPathPatterns("/content/delete_wmsx");
        ir2.addPathPatterns("/content/update_wmsx");
        ir2.addPathPatterns("/content/insert_wmsx");
        ir2.addPathPatterns("/content/delete_lfrx");
    }
}
